/*
 * @Description:
 * @Author: chenju
 * @Date: 2023-01-09 10:59:30
 * @LastEditors: chenju
 * @LastEditTime: 2023-05-19 10:28:25
 */
import { useCustomRouter } from '@/hooks/useCustomRouter'

export const useRouterSubApp = () => {
  const router = useCustomRouter()
  // 跳转到统一登录页
  function routerToCoLogin(redirect?: string, next?: any) {
    if (import.meta.env.NODE_ENV === 'development') {
      let path = '/login'
      if (redirect && redirect !== '/redirect') {
        path += `?redirect=${redirect}`
      }
      if (next) {
        next(path)
      } else {
        router.replace(path)
      }
    } else {
      router.push('/login')
    }
  }
  return {
    routerToCoLogin
  }
}
